package com.jielin.handling.entity.material;

import java.util.ArrayList;
import java.util.List;

/*多叉树类 */
public class MultipleTree {
	static List<String> list = new ArrayList<>();
	static int cnumber = 0;

	public static void getChild(List<Node> rootMenu) {
		// 子菜单
		List<Node> childList = new ArrayList<>();
		for (Node menu : rootMenu) {
			list.add(menu.getText());
			// 查看是否有子菜单
			if (menu.getChildren() != null) {
				childList = menu.getChildren();
				getChild(childList);
			} else {
				continue;
			}
		}
	}

	public static void main(String[] args) {
		List<Node> plist = new ArrayList<>();
		Node nodep = null;

		for (int i = 1; i < 5; i++) {
			nodep = new Node();
			nodep.setId(i + "");
			nodep.setText("银行" + i);
			Node nodec = null;
			List<Node> child = new ArrayList<>();

			int cnumber = 1;
			for (int j = 4; j < 7; j++) {

				nodec = new Node();
				nodec.setId(cnumber + "");
				nodec.setText(nodep.getText() + "的分行" + cnumber);
				nodec.setParentId(nodep.getId());
				child.add(nodec);
				cnumber++;
				Node nodecc = null;
				List<Node> cchild = new ArrayList<>();

				int ccnumber = 1;
				for (int j2 = 5; j2 < 10; j2++) {
					nodecc = new Node();
					nodecc.setId(ccnumber + "");
					nodecc.setText(nodec.getText() + "的行行" + ccnumber);
					nodecc.setParentId(cnumber + "");
					cchild.add(nodecc);
					ccnumber++;
				}
				nodec.setChildren(cchild);// 设置第三级节点值
				System.out.println("cchild=========" + cchild.toString());
			}

			nodep.setChildren(child);// 设置第二季节点值
			System.out.println("child=========" + child.toString());
			System.out.println("nodep=========" + nodep.toString());
			plist.add(nodep);

		}
		System.out.println("plist============" + plist.toString());
		getChild(plist);
		System.out.println("list================" + list.toString());

	}

}
